<template>
  <a-row justify="space-between" align="center" class="title-bar">
    <a-col :span="5">
      <div v-if="showTitle" class="title-left">
        <img class="icon" :src="pageTitleIcon" />
        <span>{{ titleText }}</span>
      </div>
    </a-col>
    <a-col v-if="showButton" :span="8" class="btn">
      <a-space>
        <slot name="button-list">
          <a-button type="primary" @click="handleAdd">{{ btnText }}</a-button>
        </slot>
      </a-space>
    </a-col>
  </a-row>
</template>

<script lang="ts" setup>
  import pageTitleIcon from '@/assets/images/project-setting/title-icon@2x.png';

  defineProps({
    showTitle: {
      type: Boolean,
      default: true,
    },
    showButton: {
      type: Boolean,
      default: true,
    },
    titleText: {
      type: String,
      default: '列表',
    },
    btnText: {
      type: String,
      default: '添加',
    },
  });

  const emit = defineEmits(['add']);

  const handleAdd = () => {
    emit('add');
  };
</script>

<style scoped lang="less">
  .title-bar {
    margin-bottom: 16px;
    :deep(button) {
      font-family: Source Han Sans CN-Regular, Source Han Sans CN;
    }

    .title-left {
      display: flex;
      align-items: center;
      font-size: 18px;
      font-family: Source Han Sans CN-Medium, Source Han Sans CN;
      font-weight: 500;
      color: #1d2129;
      line-height: 21px;

      .icon {
        width: 20px;
        height: 20px;
        margin-right: 8px;
      }
    }

    .btn {
      text-align: right;

      .arco-btn-size-medium {
        border-radius: var(--border-radius-medium);
      }
    }
  }
</style>
